package com.uzai.common.enums;

/**
 * 消息类型
 * @Auther: xiaoyuexl
 * @Date: 2021/8/13 11:22
 * @Description:
 */
public enum MessageTypeEnum {
    MT_TEXT(0,"文本消息"),
    MT_IMAGE(1,"图片消息"),
    MT_VOICE(2,"语音消息"),
    MT_VIDEO(3,"视频消息"),
    MT_GIF_IMAGE(4,"GIF图片"),
    MT_URL_CARD(5,"卡片消息"),
    MT_WEAPP_CARD(6,"小程序卡片"),
    MT_APP_CARD(7,"APP分享卡片"),
    MT_FILE(8,"文件"),
    MT_NAME_CARD(9,"名片"),
    MT_TRANSFERACCOUNT(10,"转账消息"),
    MT_INVITEGROUP(11,"邀请入群"),
    MT_COMMAND(12,"指令(业务类型，接受消息和发送消息都不能使用)"),
    MT_FRIEND_ADD(13,"好友添加"),
    MT_JSON(14,"json消息-特殊场景的统用消息类型");//格式：{"type":0,"data":{"test":"test"}}

    private Integer value;
    private String desc;

    MessageTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static MessageTypeEnum getById(Integer id) {
        if (id == null) {
            return null;
        }
        for (MessageTypeEnum type: MessageTypeEnum.values()) {
            if (type.getValue().intValue() == id) {
                return type;
            }
        }
        return null;
    }
}
